import pyecharts.options as opts
from pyecharts.charts import Funnel


x_data = ["展现", "点击", "访问", "咨询", "订单"]
y_data = [100, 80, 60, 40, 20]

data = [[x_data[i], y_data[i]] for i in range(len(x_data))]
print(data)
funnel = Funnel(init_opts=opts.InitOpts(width="1600px", height="800px"))
funnel.add(
    series_name="1122",
    data_pair=data,
    gap=2,
    sort_="ascending",
    tooltip_opts=opts.TooltipOpts(
        trigger="item", formatter="{a} <br/>{b} : {c}%"),
    label_opts=opts.LabelOpts(is_show=True, position="inside"),
    itemstyle_opts=opts.ItemStyleOpts(border_color="#fff", border_width=1),
)
funnel.set_global_opts(title_opts=opts.TitleOpts(title="漏斗图", subtitle="纯属虚构"))
funnel.render(path=r"./Exercise/2021-01-23/funnel漏斗图.html")
